home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d8
/
newhost.arc
/
NEWHOST.SLT
< prev
next >
Wrap
Text File
|
1989-04-04
|
52KB
|
1,442 lines
/////////////////////////////////////////////////////////////////////////////
//
// N E W H O S T . S L T
//
// Copyright (C) 1988 PTel and Colin Sampaleanu
//
// This is a Host Mode for Telix, written as a script file.
// To configure Host Mode parameters such as passwords, run the 'NCONFIG'
// script. That script is run automatically if the Host Mode configuration
// file 'NHOST.CNF' is missing.
//
// This script will only work with Hayes compatible modems, but may be
// modified for operation with othe rmodems.
//
//////////////////////////////////////////////////////////////////////////////
// Revised by Jon Fleming (BIX: jfleming) 11/25/88 to use individual
// passwords, let anyone with level 3 access get at the shell or shut
// down host mode.
// *** Modified By Al Cerny for use with BiModem Transfers. ***
//
//////////////////////////////////////////////////////////////////////////////
//
// *** Place compiled scripts NEWHOST.slc and NCONFIG.slc in directory with
// other script files. Place file message.lst in directory with Telix exe.
// Refer to Telix.doc for further instructions, if needed.
//////////////////////////////////////////////////////////////////////////////
// Parameters which can be configered.
str s[8],
address[20],
citystate[20],
zipcode[5],
voicephone[14],
modemphone[14],
password[16],
host_downloads[64], // where users may download from
host_uploads[64]; // where uploaded files go
int direct_connect = 0;
int f = 0;
str current_caller[31], // storage of current caller's name
message[512],
conn300[] = "CONNECT^M", // modem result messages for bauds
conn1200[] = "CONNECT 1200",
conn2400[] = "CONNECT 2400",
conn9600[] = "CONNECT 9600",
conn19200[] = "CONNECT 19200";
int finished_caller, // set to TRUE when must return to top
local_mode, // set to TRUE when local test mode
access_level, // access level of current caller
we_care_about_carrier = 1, // TRUE if should watch Carrier signal
already_connected = 0,
exit_requested = 0, // set to TRUE if Sysop has pressed Esc
connection_lost = 0, // set to TRUE when carrier lost
kill_user = 0, // set to TRUE when user must be purged
min_user_name = 5; // Minimum length of a user name
int old_scr_chk_key, // storage for some system variables
old_cisb_auto, // which we have to modify and put
old_zmod_auto, // back to what they were when done
old_sound;
str old_down_dir[64],
old_up_dir[64];
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
main() {
int c;
clear_scr();
if (read_host_config_file() == -1) {
prints("Unable to read NHOST.CNF...");
prints("Running NCONFIG, the Host Mode configuration script.^M^J");
call("NCONFIG");
if (read_host_config_file() == -1) {
prints("Still unable to read NHOST.CNF. Aborting Host Mode.^M^J");
return -1;
}
}
if (!check_directories()) {
prints("Either the upload or download directory as defined in the NHOST.CNF file");
prints("doesn't exist. Either create the missing directory with the DOS 'MKDIR'");
prints("command, or run the NCONFIG script to redefine what directories to use.");
prints("Aborting Host Mode.");
return -1;
}
old_scr_chk_key = _scr_chk_key;
_scr_chk_key = 0;
old_cisb_auto = _cisb_auto;
_cisb_auto = 0;
old_zmod_auto = _zmod_auto;
_zmod_auto = 0;
old_sound = _sound_on;
_sound_on = 0;
old_down_dir = _down_dir;
_down_dir = host_uploads; // these are reversed because we are now the Host
old_up_dir = _up_dir;
_up_dir = host_downloads; // these are reversed because we are now the Host
usagelog("HOST.LOG");
if (direct_connect)
we_care_about_carrier = 0;
else
we_care_about_carrier = 1;
if (!direct_connect && carrier())
already_connected = 1;
if (!direct_connect && !already_connected) {
prints("Initializing modem");
prints("To auto answer^M^J");
delay(15);
cputs_tr(_auto_ans_str);
}
while (1) {
finished_caller = kill_user = 0;
if (direct_connect)
we_care_about_carrier = 0;
else
we_care_about_carrier = 1;
if (!direct_connect) {
prints("^L^M^J");
prints("^M^J");
prints("^M^J");
prints(" ┌────────────┐");
prints(" ╒══╡ TELIX Host ╞════════════════════════════╕");
prints(" │ └────────────┘ │");
prints(" │ STATUS: Waiting for call... │");
prints(" │ ────────────────────────────────────────── │");
prints(" │ OPTIONS: Press ESC, to return to Telix │");
prints(" │ Press `L' to log on locally │");
prints(" │ │");
prints(" ╘════════════════════════════════════════════╛^M^J");
gotoxy(57,12);
do {
if (carrier()) {
local_mode = 0;
break;
}
c = inkey();
if (c) {
if (c == 27) {
exit_requested = 1;
break;
}
else if (c == 'l' || c == 'L') { // local test mode
local_mode = 1;
we_care_about_carrier = 0;
}
}
}
while (toupper(c) != 'L');
}
if (!exit_requested) {
host_send("^LTELIX HOST v2.0 ======================== Script file for Telix 3.xx^G^M^J^M^J");
prints(" SysOp: Press F1 to Chat with user.");
prints(" Press F2 to Edit messagese.");
prints(" Press F3 to use DOS functions.");
prints(" Press F4 to Hang-Up on undesireable user.");
prints(" Press F5 to end session & return to Telix.");
_sound_on=1;
tone(500, 10);
tone(900, 10);
tone(500, 10);
tone(900, 10);
tone(500, 10);
tone(900, 10);
tone(500, 10);
tone(900, 10);
tone(500, 10);
tone(900, 10);
tone(500, 10);
tone(900, 10);
tone(500, 10);
tone(900, 10);
tone(500, 10);
tone(900, 10);
tone(500, 10);
tone(900, 10);
tone(500, 10);
tone(900, 10);
tone(500, 10);
delay(25);
do_one_caller();
if ((connection_lost || kill_user) && we_care_about_carrier && carrier())
hangup(); // make sure nobody sneaks in
}
already_connected = 0;
if (exit_requested) {
if (!carrier() && !direct_connect)
cputs_tr(_mdm_init_str);
_scr_chk_key = old_scr_chk_key;
_cisb_auto = old_cisb_auto;
_zmod_auto = old_zmod_auto;
_sound_on = old_sound;
_down_dir = old_down_dir;
_up_dir = old_up_dir;
prints("^M^JHost mode script finished.");
usagelog("*CLOSE*");
return 1;
}
}
}
//////////////////////////////////////////////////////////////////////////////
do_one_caller() {
str strn[80], fname[64], temporary[1];
int option, status, c, i, i2;
access_level = 1;
if (already_connected)
prints("Already Connected!");
else if (we_care_about_carrier) {
if (!determine_baud())
; // do something else here if this is a problem
}
delay(10);
type_file("LOGO.MSG");
flushbuf();
while (1) {
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("Please enter your full name: ");
host_input_strn(current_caller, 30, 0);
host_send("^M^J");
if (finished_caller)
return;
if (strlen(current_caller) >= min_user_name) {
host_send ("^"");
host_send (current_caller);
host_send ("^", correct? (y/N): ");
host_input_strn (temporary, 30, 0);
host_send ("^M^J");
if (strcmpi (temporary, "y") == 0)
break;
}
else
host_send ("Name too short!^M^J");
}
if (access_level = ask_for_pass(3)) {
ustamp("Logon by: ", 1, 0);
ustamp(current_caller, 0, 1);
}
else {
host_send("Goodbye and call again soon!^M^J");
if (we_care_about_carrier) {
delay(10);
hangup();
}
ustamp("Failed logon attempt by ", 1, 0);
ustamp(current_caller, 0, 1);
return;
}
while (1) {
if (finished_caller)
return;
if (access_level <= 2) {
host_send(" ╒═══════════════╤═══════════════╕^M^J");
host_send(" │[F]Ile listings│[C]hat request │^M^J");
host_send(" ├───────────────┼───────────────┤^M^J");
host_send(" │[T]ype txt.file│[G]oodby-logoff│^M^J");
host_send(" ├───────────────┼───────────────┤^M^J");
host_send(" │[L]eave Message│ not in use │^M^J");
host_send(" ├───────────────┼───────────────┤^M^J");
host_send(" │[U]pload file │ not in use │^M^J");
host_send(" ├───────────────┼───────────────┤^M^J");
host_send(" │[D]ownload file│ not in use │^M^J");
host_send(" ├───────────────┼───────────────┤^M^J");
host_send(" │[B]iModem-trsf.│ not in use │^M^J");
host_send(" ├───────────────┼───────────────┤^M^J");
host_send(" │[R]ead Bu]liten│ not in use │^M^J");
host_send(" ╘═══════════════╧═══════════════╛^M^J");
host_send("^M^J");
prints(" ╒═╡ SysOp OPTIONS ╞══════════════════════════════════════╕");
prints(" │ F1 - To chat with user F2 - To edit bulletins │");
prints(" │ F3 - To use DOS functions F4 - Terminate User │");
prints(" │ F5 - To return to Telix F6 - Norton Commander │");
prints(" │────────────────────────────────────────────────────────│");
prints(" │ Online:^" Todays Date: │");
prints(" ╘════════════════════════════════════════════════════════╛");
gotoxy(22,21);
printsc(current_caller);
printsc("^"");
gotoxy(60,21);
date(curtime(), s);
printsc(s);
host_send("^M^J");
host_send("^M^JSelect... > "); }
else {
host_send(" ╒═══════════════╤═══════════════╕^M^J");
host_send(" │[F]Ile listings│[C]hat request │^M^J");
host_send(" ├───────────────┼───────────────┤^M^J");
host_send(" │[T]ype txt.file│[G]oodby-logoff│^M^J");
host_send(" ├───────────────┼───────────────┤^M^J");
host_send(" │[L]eave Message│[S]hell to DOS │^M^J");
host_send(" ├───────────────┼───────────────┤^M^J");
host_send(" │[U]pload file │ctrl-z Shut dn.│^M^J");
host_send(" ├───────────────┼───────────────┤^M^J");
host_send(" │[D]ownload file│[*] view - log │^M^J");
host_send(" ├───────────────┼───────────────┤^M^J");
host_send(" │[B]iModem-trsf.│[R]ead Bulliten│^M^J");
host_send(" ├───────────────┼───────────────┤^M^J");
host_send(" │Read [M]essages│User [H]istory │^M^J");
host_send(" ╘═══════════════╧═══════════════╛^M^J");
host_send("^M^J");
prints(" ╒═╡ SysOp OPTIONS ╞══════════════════════════════════════╕");
prints(" │ F1 - To chat with user F2 - To edit bulletins │");
prints(" │ F3 - To use DOS functions F4 - Terminate User │");
prints(" │ F5 - To return to Telix F6 - Norton Commander │");
prints(" │────────────────────────────────────────────────────────│");
prints(" │ Online:^" Todays Date: │");
prints(" ╘════════════════════════════════════════════════════════╛");
gotoxy(22,21);
printsc(current_caller);
printsc("^"");
gotoxy(60,21);
date(curtime(), s);
printsc(s);
host_send("^M^J");
host_send("^M^JSelect... > "); }
host_input_strn(strn, 1, 0);
option = toupper(subchr(strn, 0));
host_send("^M^J");
if (option == 'F') { // Files directory
if (access_level >= 2) {
host_send("Enter filespec or press <Return> for all. > ");
host_input_strn(fname, 64, 0);
host_send("^M^J");
if (just_filename(fname)) {
strn = host_downloads;
strcat(strn, fname);
}
else
strn = fname;
}
else {
strn = host_downloads;
strcat(strn, "*.*");
}
if (local_mode)
show_directory(strn, 0, we_care_about_carrier);
else
show_directory(strn, 1, we_care_about_carrier);
host_send("^M^J");
}
else if (option == 'R') {
type_file("MESSAGE.LST");
host_send("[More]");
host_input(strn, 64,0);
ustamp("User read bulletins.", 1, 1);
}
else if (option == 'M') {
if (access_level == 3) {
type_file("MESSAGE.BSE");
host_send("[More]");
host_input(strn, 64,0);
ustamp("User read messages.", 1, 1);
}
else {
host_send("Not a function, make another selection.^M^J");
delay(10);
ustamp("Read message file request denied.", 1, 1); }
}
else if (option == 'H') {
if (access_level == 3) {
type_file("USER.INF");
host_send("[More]");
host_input(strn, 64,0);
ustamp("SysOp read user history file.", 1, 1);
}
else {
host_send("Not a function, make another selection.^M^J");
delay(10);
ustamp("Read user history file denied user.", 1, 1); }
}
else if (option == '*') {
if (access_level == 3) {
type_file("HOST.LOG");
host_send("[MORE]");
host_input(strn, 64,0);
ustamp("User read host log.", 1, 1);
}
else {
host_send("Not a function, make another selection.^M^J");
delay(10);
ustamp("Read host log file denied.", 1, 1); }
}
else if (option == 'T') { // Type a file
host_send("Type what file? ");
host_input_strn(strn, 64, 0);
host_send("^M^J");
if (access_level == 1) // if access 1, name and ext only
fnstrip(strn, 3, fname);
else
fname = strn;
if (just_filename(fname)) {
strn = host_downloads;
strcat(strn, fname);
fname = strn;
}
if (!filefind(fname, 0, strn)) {
host_send("Unable to find ");
host_send(fname);
continue;
}
type_file(fname);
}
else if (option == 'L')
{
host_send("^M^J");
host_send("╔════════════════════════════════════════════════════════════════════════╗^M^J");
host_send("║ **** Please do not press <ENTER> until done with entire message! **** ║^M^J");
host_send("║ There are currently only 6 lines available............ ║^M^J");
host_send("╔═╗ Begin below: ║^M^J");
host_send(" ╚══════════════════════════════════════════════════════════════════════╝^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
gotoxy(0,5);
host_input_strn(message, 512, 0);
f = fopen("MESSAGE.BSE", "a");
fputs("^M^J", f);
fputs("Date: ", f);
date(curtime(), s);
fputs(s, f);
fputs("^M^J", f);
fputs("MESSAGE FROM: ", f);
fputs(current_caller, f);
fputs("^M^J", f);
fputs(message, f);
fputs("^M^J", f);
fclose(f);
host_send("^M^J");
host_send("Message Saved.....^M^J");
ustamp("User left message.", 1, 1);
}
else if (option == 'G') { // Goodbye (Hang-up)
host_send("^M^J");
host_send("^M^J");
host_send(" ╦════╗ ╦ ╦ ╦════╗ ╒═╕^M^J");
host_send(" ║ ║ ║ ║ ║ │ │^M^J");
host_send(" ║ ═══╣ ╚══╦══╝ ╠════╣ ╘═╛^M^J");
host_send(" ║ ║ ║ ║ ┌─┐^M^J");
host_send(" ╩════╝ ╩ ╩════╝ └─┘^M^J");
host_send("^M^J");
host_send(" Thanks for calling!^M^J");
host_send("^M^J");
host_send(" Please hang up now.... call again ya hear!!^M^J");
ustamp("User logged off.", 1, 1);
if (we_care_about_carrier) {
hangup();
}
return;
}
else if (option == 'C') { // Chat mode
host_send("^M^J");
host_send("Paging the SysOp, hang on a second!^M^J");
host_send("^M^J");
prints("^M^J");
prints("^M^J");
prints("^M^J");
prints(" ╔═══╡ User would like to chat with you. ╞═════════════════╗");
prints(" ║ ║");
prints(" ║ OPTIONS: Press space bar to chat with user, ║");
prints(" ║ or any other key to say your unavailable. ║");
prints(" ║ ║");
prints(" ╚═════════════════════════════════════════════════════════╝^M^J");
prints("^M^J");
prints("^M^J");
prints("^M^J");
prints("^M^J");
c = 0;
_sound_on = 1;
for (i = 8; i && !c; --i) {
if (we_care_about_carrier && !carrier()) {
prints("^M^JConnection has been lost, call terminated.^M^J");
connection_lost = 1;
finished_caller = 1;
break;
}
cputc('^G');
tone(523, 20);
tone(659, 20);
tone(523, 20);
tone(659, 20);
tone(523, 20);
tone(659, 20);
for (i2 = 30; i2 && (c = inkey()) == 0; --i2)
delay(1);
}
_sound_on = 0;
if (finished_caller)
continue;
if (c != ' ' || !c) {
host_send("Sorry, The Sysop is unavailable^M^J");
delay(15);
ustamp("Users chat request denied.", 1, 1);
continue;
}
host_send("The Sysop is here!^M^J");
chatmode(1);
}
else if (option == 'B') { //BiModem Transfer
host_send("^M^JYou have selected BiModem, A DUAL Transfer method.^M^J");
host_send("Set-Up YOUR end NOW...I am READY for the transfer. When^M^J");
host_send("your end prompts to start my end; Type a B and ENTER...^M^J");
host_input_strn(strn, 1, 0);
dos("bimodem /R",0);
clear_scr();
dos("del BiModem.Pth");
}
else if (option == 'U') { // User upload
if (! (option = host_get_prot()))
continue;
status = 1;
if (option == 'T' || option == 'M' || option == 'S' ||
option == 'Y' || option == 'Z' || option == 'E') {
send_transfer_msg();
status = receive(option, "");
}
else {
host_send("Upload what file? ");
host_input_strn(strn, 48, 0);
host_send("^M^J");
if (!strn)
continue;
if (access_level == 1) // if access 1, name and ext only
fnstrip(strn, 3, fname);
else
fname = strn;
if (just_filename(fname)) {
strn = host_uploads;
strcat(strn, fname);
fname = strn;
}
if (filefind(fname, 23, strn))
host_send("File already exists!^M^J");
else {
send_transfer_msg();
status = receive(option, fname);
}
}
if (status == -2) // Carrier lost
connection_lost = finished_caller = 1;
else if (status == -1)
host_send("^GOne or more files not received!^M^J");
}
else if (option == 'D') { // User download
if (! (option = host_get_prot()))
continue;
host_send("Download what file(s)? ");
host_input_strn(strn, 48, 0);
host_send("^M^J");
if (!strn)
continue;
if (access_level == 1) // if level 1, keep only name & ext
fnstrip(strn, 3, fname);
else
fname = strn;
if (just_filename(fname)) {
strn = host_downloads;
strcat(strn, fname);
fname = strn;
}
if (!filefind(fname, 0, strn)) {
host_send("Unable to find any matching file(s)!^M^J");
continue;
}
status = 1;
send_transfer_msg();
status = send(option, fname);
if (status == -2) // Carrier lost
connection_lost = finished_caller = 1;
else if (status == -1)
host_send("^GOne or more files not received!^M^J");
}
else if (option == 'S') { // Remote shell
if (get_port() !=1 && get_port() !=2) {
host_send("Shell not supported due to DOS limits!^M^J");
continue;
}
if (access_level == 3) { // Need access level 3 to shell
host_send("Type EXIT and then press Return to come back.^M^J");
if (get_baud() == 300)
delay(10);
strn = "COM";
setchr (strn, 3, get_port() + '0');
if (!local_mode)
if (redirect_dos(strn) == -1) // redirect DOS input and output
continue;
dos("", 0); // actually call the shell
if (!local_mode)
redirect_dos(""); // very important to put things back to norm
}
else {
host_send ("Not a function, make another selection^M^J");
delay(10);
ustamp("User denied <shell option>.", 1, 1);
}
}
else if (option == '^Z') { // Shut down Host Mode
if (access_level == 3) {
host_send("Shutting down Host Mode. Goodbye!^M^J");
if (we_care_about_carrier)
hangup();
ustamp("User shut down Host Mode.", 1, 1);
finished_caller = 1;
exit_requested = 1;
}
else {
host_send ("Not a function, make another selection^M^J");
delay(10);
ustamp("User denied <shut down option>.", 1, 1);
}
}
}
}
//////////////////////////////////////////////////////////////////////////////
host_get_prot() {
str prot[1];
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send(" ╦══╗ ╦══╗ ╔══╗ ╔═╦═╗ ╔══╗ ╔══╗ ╔══╗ ╦ ╔══╗ ^M^J");
host_send(" ╠══╝ ╠═╦╝ ║ ║ ║ ║ ║ ║ ║ ║ ║ ╚══╗ ^M^J");
host_send(" ╩ ╩ ╚╝ ╚══╝ ╩ ╚══╝ ╚══╝ ╚══╝ ╚══╝ ╚══╝ ^M^J");
host_send(" ┌────────────┐ ^M^J");
host_send(" ╔═╡ TELIX Host ╞╤════════════════╤═══════════════╤════════════════╗^M^J");
host_send(" ║ └────────────┘│ │ │ ║^M^J");
host_send(" ║ (X)modem │ Ymod(E)m-g │ (G)-1k-Xmodem │ (S)ealink ║^M^J");
host_send(" ╟───────────────┼────────────────┼───────────────┼────────────────╢^M^J");
host_send(" ║ (1)k-Xmodem │ (M)odem-7 │ (Y)modem │ (Z)modem ║^M^J");
host_send(" ║ │ │ │ ║^M^J");
host_send(" ╚═══════════════╧════════════════╧═══════════════╧════════════════╝^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^J");
host_send("^M^JSelect... > ");
host_input_strn(prot, 1, 0);
host_send("^M^J");
if (strposi("MSX1GYEZ", prot, 0) == -1) // if illegal prot
prot = ""; // return 0
return (toupper(subchr(prot, 0)));
}
//////////////////////////////////////////////////////////////////////////////
send_transfer_msg() {
host_send("^M^J");
host_send(" ╒══╡ File Transfer ╞═════════════════════╕^M^J");
host_send(" │ Status: Ready to transfer file(s).. │^M^J");
host_send(" │────────────────────────────────────────│^M^J");
host_send(" │ Option: Press Ctrl-X at least twice │^M^J");
host_send(" │ to abort file transfer..... │^M^J");
host_send(" ╘════════════════════════════════════════╛^M^J");
}
//////////////////////////////////////////////////////////////////////////////
// Determine the baud rate once a Carrier Detect Signal has been detected
// Since no characters were read, the 'CONNECT' string should still be
// in the receive buffer.
determine_baud() {
int t3, t12, t24, t96, t192;
int tmark, stat;
int new_baud = 0;
printsc("Determining baud... ");
track_free(0); // clear all existing tracks
t3 = track(conn300, 0); // check for connect strings
t12 = track(conn1200, 0);
t24 = track(conn2400, 0);
t96 = track(conn9600, 0);
t192 = track(conn19200, 0);
tmark = timer_start(30); // wait up to 3 seconds for string
while (!time_up(tmark)) {
if (!carrier()) {
track_free(0); // clear all existing tracks
return 0;
}
if (cinp_cnt())
track_addchr(cgetc());
stat = track_hit(0);
if (stat == 0)
continue;
if (stat == t3)
new_baud = 300;
else if (stat == t24)
new_baud = 2400;
else if (stat == t96)
new_baud = 9600;
else if (stat == t192)
new_baud = 19200;
else
new_baud = 1200;
break; // have baud rate, get out
}
if (!new_baud) { // time-up without CONNECT string
prints("Failed!");
track_free(0); // clear all existing tracks
return 0;
}
printn(new_baud);
prints("");
set_cparams(new_baud, get_parity(), get_datab(), get_stopb());
track_free(0); // clear all existing tracks
return 1; // indicate success
}
//////////////////////////////////////////////////////////////////////////////
type_file(str fname) {
int f, control_z_loc;
str buf[100];
int ichar, lines_sent = 0;
if (not (f = fopen(fname, "r")))
return -1;
host_send("^M^J");
while (1) {
if (we_care_about_carrier) {
if (!carrier()) {
connection_lost = 1;
finished_caller = 1;
fclose(f);
return 0;
}
}
if (fgets(buf, 80, f) == -1) {
fclose(f);
return 1;
}
if ((control_z_loc = strpos (buf, "^Z", 0)) >= 0) {
if (control_z_loc == 0) {
fclose (f);
return 1;
}
else {
setchr (buf, control_z_loc, 0);
}
}
host_send(buf);
host_send("^M^J");
++lines_sent;
if (lines_sent >= 22) {
lines_sent = 0;
host_send("[More]");
host_input(0);
if (finished_caller) { // if user inactivity
fclose(f);
return 0;
}
host_send("^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H");
}
while (cinp_cnt()) {
ichar = cgetc();
if (ichar == '^C' || ichar == '^K') {
host_send("^M^J");
fclose(f);
return 1;
}
}
}
}
//////////////////////////////////////////////////////////////////////////////
host_send(str outstr) {
printsc(outstr);
if (!local_mode)
cputs(outstr);
}
//////////////////////////////////////////////////////////////////////////////
host_send_c(int chr) {
printc(chr);
if (!local_mode)
cputc(chr);
}
//////////////////////////////////////////////////////////////////////////////
host_input_strn(str buf, int maximum, int echo_asterisk) {
//Rev 11/25/88 by Jon Fleming to echo a string of asterisks if
// "echo_asterisk" is non-zero, echo the input string if "echo_asterisk"
// is zero.
int i = 0, key;
while (1) {
key = host_input(echo_asterisk);
if (!key) { // timeout or user disconnect
setchr(buf, 0, 0); // set string to empty
return 0; // indicate there is a problem
}
if (key == '^M')
break;
if (key == 127 || key == 8) {
if (i) {
--i;
host_send_c(key);
}
continue;
}
if (i < maximum) {
setchr(buf, i, key);
i = i + 1;
}
else
i = i + 1;
}
if (i > maximum)
i = maximum;
setchr(buf, i, '^0');
if (subchr(buf, 0))
return 1;
else
return 0;
}
//////////////////////////////////////////////////////////////////////////////
host_input(int echo_asterisk) {
// Rev 11/25 88 by Jon Fleming to echo asterisk if "echo_asterisk" is
// non-zero, to echo the input character if "echo_asterisk" is zero.
int c, t;
t = timer_start(2400); // 4 minutes inactivity allowed
while (1) {
if (time_up(t) && !direct_connect) {
host_send("^M^J^M^JInactivity period too long. Connection terminated!^M^J");
ustamp("User terminated 4 min. inactivity.", 1, 1);
delay(10);
if (we_care_about_carrier)
hangup();
finished_caller = 1;
kill_user = 1;
return 0;
}
if (we_care_about_carrier)
if (!carrier()) {
prints("^M^JConnection has been lost, call terminated.^M^J");
connection_lost = 1;
finished_caller = 1;
return 0;
}
if ((c = inkey()) != 0) {
if (c == 0x3f00) { // F5 key, sysop wants to exit to Telix.
host_send("^M^J* SysOp Terminated Session *^M^J");
ustamp("SysOp terminated host session.", 1, 1);
finished_caller = 1;
exit_requested = 1;
return 0;
}
else if (c == 0x3e00) { // F4 Hang up on user
ustamp("User terminated!", 1, 1);
host_send("User terminated!^M^J");
delay(10);
if (we_care_about_carrier)
hangup();
finished_caller = 1;
kill_user = 1;
return 0;
}
else if (c == 0x3b00) { // F1 Chat w/User
host_send("^M^J^M^JSysOp breaking in for chat! ");
ustamp("SysOp broke in, for chat w/user.", 1, 1);
delay(20);
chatmode();
return 0;
}
else if (c == 0x3c00) { // F2 Edit message.
dos("q message.lst",1);
return 0;
}
else if (c == 0x4000) { // F6 Editor
dos("nc.exe",1);
return 0;
}
else if (c == 0x3d00) { /// F3 SysOp using Dos functions
host_send("^M^J^M^J* Please Wait, SysOp is using DOS functions *");
ustamp("SysOp used DOS functions.", 1, 1);
dosfunction();
host_send("^M^J^M^J* Thanks for waiting *^M^J^M^J");
delay(10);
return 0;
}
else if (c <= 255) {
if (c != 8 && c != 127) {
if ( (echo_asterisk) && (c != 13) ) {
host_send_c ('*');
}
else {
host_send_c(c);
}
}
return c;
}
}
if (!local_mode)
if (cinp_cnt()) {
c = cgetc();
if (c != 8 && c != 127) {
if ( (echo_asterisk) && (c !=13) ) {
host_send_c ('*');
}
else {
host_send_c(c);
}
}
return c;
}
}
}
//////////////////////////////////////////////////////////////////////////////
// This routine maintains an ASCII file in the Telix files directory called
// PASSWORD.TLX. The format for each line is:
// name;password;access_level (optional comment)
// The name, password, and acces_level fields MUST be seperated by
// semicolons
// The routine searches the file for a line on which the "name" field
// matches the global variable "current_caller" (not case sensitive).
// If a match is found, and the user can type a password that matches
// the "password" field (not case sensitive), the routine returns
// the integer "access_level".
// If no match is found, the user is given an opportunity to reigister
// (at access level 1).
// If the user registers, the file is updated with the new user name,
// password, and access level (1), the routine returns 1.
// If the user does not register, or if the user cannot match the password
// in the file in "maxtries", or if the user registers and cannot match
// the password he/she chose in "maxtries", the routine retuns 0.
ask_for_pass(int maxtries) {
str password_file[64], line_from_file[80], address_from_file[20],
citystate_from_file[20], zipcode_from_file[5],
voicephone_from_file[14], modemphone_from_file[14],
password_from_file[16], name_from_file[31], temporary[16],
typed_password[16];
int password_file_handle, field_length, field_start,
found_password = 0, access_from_file, counter = 0,
file_ends_in_control_z = 0, line_number = 0;
// Build password file name
password_file = _telix_dir;
strcat (password_file, "PASSWORD.TLX");
// Try to open password file
if (password_file_handle = fopen (password_file, "r")) {
// Read next line from file.
while (fgets (line_from_file, 64, password_file_handle) != -1) {
// Check for ^Z termination
if (line_from_file == "^Z") {
file_ends_in_control_z = 1;
break;
}
line_number = line_number + 1;
// If line is long enough . . .
if (strlen (line_from_file) >= min_user_name+4) {
// Get length of name
if ( (field_length = strchr (line_from_file, 0, ';')) > 0) {
// Get name
substr (line_from_file, 0, field_length, name_from_file);
// If name matches . . . .
if (strcmpi (name_from_file, current_caller) == 0) {
// Get password
field_start = field_length + 1;
if ( (field_length = strchr (line_from_file, field_start, ';') - field_start) > 0) {
substr (line_from_file, field_start, field_length, password_from_file);
// Get access level
field_start = field_start + field_length + 1;
substr (line_from_file, field_start, 1, temporary);
access_from_file = stoi (temporary);
// Set flag that we got an old user
found_password = 1;
break;
}
else {
password_file_error (line_number, line_from_file, "no second semicolon");
}
}
}
else {
password_file_error (line_number, line_from_file, "no first semicolon");
}
}
else {
password_file_error (line_number, line_from_file, "line too short");
}
}
fclose (password_file_handle);
}
if (found_password) {
// Password is on file; ask for it
host_send ("Password...asterisks will echo: ");
for (counter = 1; counter <= maxtries; counter = counter + 1) {
host_input_strn (typed_password, 16, 1);
// If a match
if (strcmpi (typed_password, password_from_file) == 0) {
host_send ("^M^J");
return (access_from_file);
}
if (counter <maxtries) {
host_send ("^M^JDoes not match password on file! Please try again: ");
}
else {
host_send ("^M^JMaximum number of tries exceeded!^M^J");
}
}
}
// Password is not on file
else {
// Offer chance to register
host_send ("No user ^"");
host_send (current_caller);
host_send ("^" found in user file.^M^JDo you want to register? (Y/N): ");
host_input_strn (temporary, 1, 0);
host_send ("^M^J");
// If user doesn't want to register
if (not ((temporary == "Y") || (temporary == "y"))) {
return (0);
}
while (1) {
host_send ("^M^J");
host_send ("^M^J");
host_send ("What is your address ?(20 characters max.): ");
host_input_strn (address_from_file, 20, 0);
host_send ("^M^J");
host_send ("^"");
host_send (address_from_file);
host_send ("^", correct? (y/N): ");
host_input_strn (temporary, 20, 0);
host_send ("^M^J");
if (strcmpi (temporary, "y") == 0)
break; }
while (1) {
host_send ("^M^J");
host_send ("^M^J");
host_send("What is your City & State ?(20 characters max.): ");
host_input_strn (citystate_from_file, 20, 0);
host_send ("^M^J");
host_send ("^"");
host_send (citystate_from_file);
host_send ("^", correct? (y/N): ");
host_input_strn (temporary, 20, 0);
host_send ("^M^J");
if (strcmpi (temporary, "y") == 0)
break; }
while (1) {
host_send ("^M^J");
host_send ("^M^J");
host_send ("What is your Zip Code ?(5 characters max.): ");
host_input_strn (zipcode_from_file, 5, 0);
host_send ("^M^J");
host_send ("^"");
host_send (zipcode_from_file);
host_send ("^", correct? (y/N): ");
host_input_strn (temporary, 5, 0);
host_send ("^M^J");
if (strcmpi (temporary, "y") == 0)
break; }
while (1) {
host_send ("^M^J");
host_send ("^M^J");
host_send ("What is your voice phone no. (example 214-283-3265): ");
host_input_strn (voicephone_from_file, 14, 0);
host_send ("^M^J");
host_send ("^"");
host_send (voicephone_from_file);
host_send ("^", correct? (y/N): ");
host_input_strn (temporary, 14, 0);
host_send ("^M^J");
if (strcmpi (temporary, "y") == 0)
break; }
while (1) {
host_send ("^M^J");
host_send ("^M^J");
host_send ("What is your modem phone no. (example 214-283-3265): ");
host_input_strn (modemphone_from_file, 14, 0);
host_send ("^M^J");
host_send ("^"");
host_send (modemphone_from_file);
host_send ("^", correct? (y/N): ");
host_input_strn (temporary, 14, 0);
host_send ("^M^J");
if (strcmpi (temporary, "y") == 0)
break; }
host_send ("^M^J");
host_send ("^M^J");
host_send ("Pick a password (16 characters max.): ");
host_input_strn (password_from_file, 16, 1);
// Make sure password is right
host_send ("^M^JRe-enter your password to verify: ");
for (counter = 1; counter <= maxtries; counter = counter + 1) {
host_input_strn (typed_password, 16, 1);
// If all is ok
if (strcmpi (typed_password, password_from_file) == 0) {
// Build new line for password file
line_from_file = current_caller;
strcat (line_from_file, ";");
strcat (line_from_file, password_from_file);
strcat (line_from_file, ";1 ** NEW USER ** ");
date (curtime(), temporary);
strcat (line_from_file, temporary);
// Open password file for appending
password_file_handle = fopen (password_file, "a+");
if (file_ends_in_control_z) {
fseek (password_file_handle, -1, 2);
}
// Now we can write the line
fwrite (line_from_file, strlen (line_from_file), password_file_handle);
fwrite ("^M^J", 2, password_file_handle);
fclose (password_file_handle);
host_send ("^M^J");
// Return access level
f = fopen("USER.INF", "a+");
fputs("^M^J", f);
fputs("Registered: ", f);
date(curtime(), s);
fputs(s, f);
fputs("^M^J", f);
fputs("User name: ", f);
fputs(current_caller, f);
fputs("^M^J", f);
fputs("Address: ", f);
fputs(address_from_file, f);
fputs("^M^J", f);
fputs("Location: ", f);
fputs(citystate_from_file, f);
fputs(" ", f);
fputs(zipcode_from_file, f);
fputs("^M^J", f);
fputs("Voice Phone: ",f);
fputs(voicephone_from_file, f);
fputs("^M^J", f);
fputs("Modem Phone: ",f);
fputs(modemphone_from_file, f);
fputs("^M^J", f);
fputs("Password: ", f);
fputs(password_from_file, f);
fputs("^M^J", f);
fclose(f);
host_send("^M^J");
host_send("Regristration Information Saved.....^M^J");
ustamp("User Registered.", 1, 1);
return (1);
}
if (counter < maxtries){
host_send ("^M^JDoes not match! Please try again: ");
}
else {
host_send ("^M^JMaximum number of tries exceeded!^M^J");
}
}
}
return (0);
}
//////////////////////////////////////////////////////////////////////////////
// A routine to print an error message to the local screen when something
// is wrong with the password file
password_file_error (int line_number, str line, str error_specifier) {
str line_number_string[4];
itos (line_number, line_number_string);
prints ("");
printsc ("Bad line ");
printsc (line_number_string);
prints (" in password file:");
printsc (" ^"");
printsc (line);
prints ("^"");
prints (error_specifier);
return (1);
}
//////////////////////////////////////////////////////////////////////////////
//Rev 11/25/88 by Jon Fleming to not read the lines from the old host mode
// configuration file that are no longer applcable.
read_host_config_file() {
str config_file_name[80], buffer [32];
int config_file_handle;
config_file_name = _telix_dir;
strcat(config_file_name, "NHOST.CNF");
if (not (config_file_handle = fopen(config_file_name, "r"))) {
printsc("Can't open ");
prints(config_file_name);
return -1;
}
if (fgets(host_downloads, 80, config_file_handle) == -1) {
fclose(config_file_handle);
return -1;
}
if (fgets(host_uploads, 80, config_file_handle) == -1) {
fclose(config_file_handle);
return -1;
}
if (fgets(buffer, 80, config_file_handle) == -1) {
fclose(config_file_handle);
return -1;
}
direct_connect = (toupper(subchr(buffer, 0)) == 'D');
fclose(config_file_handle);
return 1;
}
//////////////////////////////////////////////////////////////////////////////
check_directories() {
str s[80];
int i, a;
// first remove trailing slashes
s = host_uploads;
i = strlen(s);
if (i > 0)
if (subchr(s, i - 1) == '\' || subchr(s, i - 1) == '/')
setchr(s, i - 1, 0);
if (s && !(strlen(s) == 2 && subchr(s, 1) == ':')) {
a = fileattr(s);
if (a == -1 || !(a & 16))
return 0; // not a directory or doesn't exist
}
s = host_downloads;
i = strlen(s);
if (i > 0)
if (subchr(s, i - 1) == '\' || subchr(s, i - 1) == '/')
setchr(s, i - 1, 0);
if (s && !(strlen(s) == 2 && subchr(s, 1) == ':')) {
a = fileattr(s);
if (a == -1 || !(a & 16))
return 0; // not a directory or doesn't exist
}
return 1;
}
//////////////////////////////////////////////////////////////////////////////
// returns TRUE if passed filespec is just a filename. Also handles the
// forward slash as a path separator.
just_filename(str filespec) {
int slash, space;
if (strpos(filespec, ":", 0) != -1)
return 0;
if (strpos(filespec, "\", 0) != -1)
return 0;
if ((slash = strpos(filespec, "/")) == -1)
return 1;
space = strpos(filespec, " ");
if (space == -1)
return 0;
if (space < slash)
return 1;
return 0;
}
//////////////////////////////////////////////////////////////////////////////